version 8.2
capture clear
capture log close
set more off
set mem 510m
set mat 800

use "data_mcgill_final.dta"
	

	

*controls:
global list_controls fshortdum2 fshortdum3 fshortdum4 fshortdum5 female origin3_dum1 origin3_dum2 origin3_dum3 origin3_dum5 class_clean_dum1 class_clean_dum3 class_clean_dum4
global list_controls_diversity number_female div_group_field div_group_origin4 number_third_fourth group_of_3 
	
	
***table 2: Peer review increases effort, by the same order of magnitude as peer pressure, and takes away peer pressure:

*****drop the emails!!
drop if email_dummy_group==1



reg effort_final monitoring teamwork Fall201*, robust cluster(term_group_T_P)
sum effort_final if monitoring==0
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table3.xls",  adec(2) addstat("Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("Effort") replace


dprobit effort_final monitoring teamwork Fall201*, robust cluster(term_group_T_P)
sum effort_final if monitoring==0
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table3.xls",  adec(2) addstat("Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("Effort") append

reg effort_final monitoring quiz_bef quiz_bef_monitoring teamwork Fall201*, robust cluster(term_group_T_P)
sum effort_final if monitoring==0
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table3.xls",  adec(2) addstat("Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("Effort") append

reg effort_final monitoring mean_group_quiz mon_mean_group_quiz ///
teamwork Fall201*, robust cluster(term_group_T_P)
test _b[mean_group_quiz]+_b[mon_mean_group_quiz]=0
local ttest1=r(p)
sum effort_final if monitoring==0
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table3.xls",  adec(2) addstat("P-val Sum Coeff Peer Review", `ttest1', "Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("Effort") append

reg effort_final monitoring mean_group_quiz mon_mean_group_quiz ///
quiz_bef quiz_bef_monitoring quiz_bef_mean_group_quiz quiz_bef_mon_mean_group_quiz ///
teamwork Fall201*, robust cluster(term_group_T_P)
test _b[mean_group_quiz]+_b[mon_mean_group_quiz]=0
local ttest1=r(p)
sum effort_final if monitoring==0
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table3.xls",  adec(2) addstat("P-val Sum Coeff Peer Review", `ttest1', "Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("Effort") append

***low/high ability:
reg effort_final monitoring mean_group_quiz mon_mean_group_quiz teamwork Fall201* if bad_50==1, robust cluster(term_group_T_P)
test _b[mean_group_quiz]+_b[mon_mean_group_quiz]=0
local ttest1=r(p)
sum effort_final if monitoring==0&bad_50==1
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table3.xls",  adec(2) addstat("P-val Sum Coeff Peer Review", `ttest1', "Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("Effort: Low-ability") append

reg effort_final monitoring mean_group_quiz mon_mean_group_quiz teamwork Fall201* if good_50==1, robust cluster(term_group_T_P)
test _b[mean_group_quiz]+_b[mon_mean_group_quiz]=0
local ttest1=r(p)
sum effort_final if monitoring==0&good_50==1
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table3.xls",  adec(2) addstat("P-val Sum Coeff Peer Review", `ttest1', "Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("Effort: High-ability") append

****add controls:
reg effort_final monitoring mean_group_quiz mon_mean_group_quiz ///
quiz_bef quiz_bef_monitoring quiz_bef_mean_group_quiz quiz_bef_mon_mean_group_quiz ///
teamwork Fall201* $list_controls, robust cluster(term_group_T_P)
test _b[mean_group_quiz]+_b[mon_mean_group_quiz]=0
local ttest1=r(p)
sum effort_final if monitoring==0
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table3.xls",  adec(2) addstat("P-val Sum Coeff Peer Review", `ttest1', "Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("Effort") append

reg effort_final monitoring mean_group_quiz mon_mean_group_quiz ///
quiz_bef quiz_bef_monitoring quiz_bef_mean_group_quiz quiz_bef_mon_mean_group_quiz ///
sd_group_quiz teamwork Fall201* $list_controls $list_controls_diversity, robust cluster(term_group_T_P)
test _b[mean_group_quiz]+_b[mon_mean_group_quiz]=0
local ttest1=r(p)
sum effort_final if monitoring==0
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table3.xls", sortvar(monitoring quiz_bef quiz_bef_monitoring ///
mean_group_quiz mon_mean_group_quiz quiz_bef_mean_group_quiz quiz_bef_mon_mean_group_quiz) ///
adec(2) addstat("P-val Sum Coeff Peer Review", `ttest1', "Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("Effort") append





***Other measures of effort

reg effort_final monitoring mean_group_quiz mon_mean_group_quiz ///
quiz_bef quiz_bef_monitoring quiz_bef_mean_group_quiz quiz_bef_mon_mean_group_quiz ///
sd_group_quiz teamwork Fall201* $list_controls $list_controls_diversity, robust cluster(term_group_T_P)
test _b[mean_group_quiz]+_b[mon_mean_group_quiz]=0
local ttest1=r(p)
sum effort_final if monitoring==0
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table4.xls",  adec(2) addstat("P-val Sum Coeff Peer Review", `ttest1', "Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("Effort")replace


label variable appointment "Post: Appointment"
label variable proactive "Post: Proactive"


label variable final_mycontrib "Contribution (rated by self)"
label variable final_mean_mycontrib "Contribution (rated by peers)"


hist final_mycontrib, start(0) width(1) xscale(range(0 60)) xlabel(0(10) 60) percent
graph save "Figure 3 (rated by self).gph", replace
graph export "Figure 3 (rated by self).png", replace
hist final_mean_mycontrib,  start(0) width(1) xscale(range(0 60)) xlabel(0(10) 60) percent
graph save "Figure 3 (rated by peers).gph", replace
graph export "Figure 3 (rated by peers).png", replace


sum final_mycontrib final_mean_mycontrib

local list_outcomes effort_mean final_mycontrib final_mean_mycontrib posting appointment proactive freerider_reported final_12_me delta_quiz 


foreach var of local list_outcomes{

local lab : var label `var'

reg `var' monitoring mean_group_quiz mon_mean_group_quiz ///
quiz_bef quiz_bef_monitoring quiz_bef_mean_group_quiz quiz_bef_mon_mean_group_quiz ///
sd_group_quiz teamwork Fall201* $list_controls $list_controls_diversity, robust cluster(term_group_T_P)
test _b[mean_group_quiz]+_b[mon_mean_group_quiz]=0
local ttest1=r(p)
sum `var' if monitoring==0
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table4.xls", sortvar(monitoring quiz_bef quiz_bef_monitoring ///
mean_group_quiz mon_mean_group_quiz quiz_bef_mean_group_quiz quiz_bef_mon_mean_group_quiz) ///
 adec(2) addstat("P-val Sum Coeff Peer Review", `ttest1', "Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("`lab'") append


}






*****Table 4: peer review increases team productivity
	
	
reg grade_teamwork_t monitoring_t quiz_bef_t teamwork Fall201* number_female_t div_group_field_t div_group_origin4_t number_third_fourth_t group_of_3_t sd_group_quiz_t if group_obs==1, robust
sum grade_teamwork_t if monitoring_t==0
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table5.xls",  adec(2) addstat("Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("Grade teamwork") replace





****without contaminated control:

reg effort_final monitoring mean_group_quiz mon_mean_group_quiz ///
quiz_bef quiz_bef_monitoring quiz_bef_mean_group_quiz quiz_bef_mon_mean_group_quiz ///
sd_group_quiz teamwork Fall201* $list_controls $list_controls_diversity if contaminated_control==0, robust cluster(term_group_T_P)
test _b[mean_group_quiz]+_b[mon_mean_group_quiz]=0
local ttest1=r(p)
sum effort_final if monitoring==0
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table6.xls",  adec(2) addstat("P-val Sum Coeff Peer Review", `ttest1', "Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("Effort")replace

label variable appointment "Post: Appointment"
label variable proactive "Post: Proactive"


local list_outcomes effort_mean posting appointment proactive freerider_reported final_12_me delta_quiz 


foreach var of local list_outcomes{

local lab : var label `var'

reg `var' monitoring mean_group_quiz mon_mean_group_quiz ///
quiz_bef quiz_bef_monitoring quiz_bef_mean_group_quiz quiz_bef_mon_mean_group_quiz ///
sd_group_quiz teamwork Fall201* $list_controls $list_controls_diversity if contaminated_control==0, robust cluster(term_group_T_P)
test _b[mean_group_quiz]+_b[mon_mean_group_quiz]=0
local ttest1=r(p)
sum `var' if monitoring==0
local mean_dep_var=r(mean)
local sd_dep_var=r(sd)
outreg2 using "Table6.xls", sortvar(monitoring quiz_bef quiz_bef_monitoring ///
mean_group_quiz mon_mean_group_quiz quiz_bef_mean_group_quiz quiz_bef_mon_mean_group_quiz) ///
 adec(2) addstat("P-val Sum Coeff Peer Review", `ttest1', "Mean control group", `mean_dep_var', "SD control group", `sd_dep_var') label bdec(2) se sdec(2) ctitle("`lab'") append


}










exit

